﻿using Microsoft.Extensions.Hosting;
using System.Threading;
using System.Threading.Tasks;

namespace Handday.Erp.Core
{
    /// <summary>
    /// 后台任务服务BackgroundService
    /// </summary>
    public class JobHostService : BackgroundService
    {
        private readonly IBackgroundJobService _backgroundJobService;

        /// <summary>
        /// ctor
        /// </summary>
        public JobHostService(IBackgroundJobService backgroundJobService)
        {
            _backgroundJobService = backgroundJobService;
        }

        /// <summary>
        /// ExecuteAsync
        /// </summary>
        protected async override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await _backgroundJobService.Execute(stoppingToken);
        }
    }
}
